(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/resources/Script/Ssg/Utils/TextUtil.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '721e4EeMrFAWZczXz6YUgPO', 'TextUtil', __filename);
// Script/Ssg/Utils/TextUtil.js

"use strict";

var JsonUtil = require('JsonUtil');

window.TextUtil = function () {

    var _instance;

    function init() {

        var TextMgrObj = {

            _isLoadFile: false,
            _loadIndex: 0,
            _textMap: new Map(),

            getValue: function getValue(key) {
                return this._textMap.get(key);
            },

            initData: function initData() {

                JsonUtil.loadFile("resources/Json/texts.json", true, function (res) {
                    if (!res) {
                        if (TextMgrObj._loadIndex <= 1) {
                            setTimeout(function () {
                                TextMgrObj.initData();
                            }, 50);
                            ++TextMgrObj._loadIndex;
                        }
                    } else {
                        TextMgrObj._textMap = new Map();
                        for (var i = 0; i < res.length; ++i) {
                            if (UIHelper.isChinese()) {
                                TextMgrObj._textMap.set(res[i].TID, res[i].CN);
                            } else {
                                TextMgrObj._textMap.set(res[i].TID, res[i].EN);
                            }
                            // cc.log("TextMgrObj._textMap: " +   TextMgrObj._textMap.get(res[i].TID));
                        }
                        TextMgrObj._isLoadFile = true;
                    }
                });
            }

        };

        TextMgrObj.initData();

        return TextMgrObj;
    }

    var _static = {

        getInstance: function getInstance() {
            if (this._instance === undefined) {
                this._instance = new init();
            } else if (!this._instance._isLoadFile) {
                this._instance.initData();
            }
            return this._instance;
        }
    };
    return _static;
}();

module.exports = TextUtil;

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=TextUtil.js.map
        